package chu.dejian.widget.chartView;

import android.content.Context;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import chu.dejian.entity.RecordEntity;

/**
 * Created by Administrator on 2015/12/19 0019.
 */
public class DialogBPChartUtils extends BaseBPChartUtils {
    private List<RecordEntity> recordEntityList;
    public DialogBPChartUtils(Context context) {
        super(context);
    }

    public DialogBPChartUtils(Context context, int lineColor, boolean showPoint) {
        super(context, lineColor, showPoint);
    }

    @Override
    public void setRecordEntityList(List<RecordEntity> recordEntityList) {
        if(recordEntityList == null || recordEntityList.size() == 0) return;
        this.recordEntityList = recordEntityList;
        int size = recordEntityList.size();
        double[] sysArray = new double[size];
        double[] diaArray = new double[size];
        String[] xFirstlabelArray = new String[size];
        String[] xSecondlabelArray = new String[size];
        for(int i = 0; i < size; i++){
            final RecordEntity recordEntity = recordEntityList.get(i);
            sysArray[i] = recordEntity.systolic;
            diaArray[i] = recordEntity.diastolic;
            xFirstlabelArray[i] = new SimpleDateFormat("MM.dd").format(recordEntity.getMeasureDateTime());
            xSecondlabelArray[i] = new SimpleDateFormat("HH:mm").format(recordEntity.getMeasureDateTime());
        }
        addLine(getPointDataSeries("SYS",sysArray), getLineSeriesRender(lineColor), getSysLevelRender());
        addLine(getPointDataSeries("DIA",diaArray), getLineSeriesRender(lineColor2), getDiaLevelRender());
        setXFirstLabels(xFirstlabelArray);
        setXSecondLabels(xSecondlabelArray);
    }

    @Override
    public List<RecordEntity> getShownRecordList() {
        return recordEntityList;
    }

    @Override
    public List<List<RecordEntity>> getGroupedRecordLists() {
        return null;
    }
}
